/* eslint-disable */
import { utilJs } from "@/utils/common.js";
function initCpypto() {
  if(window.CryptoJS){
    return new Promise(function(resolve,reject){
      resolve();
    })
  }
  return utilJs.syncLoadJs('https://assets.ckjr001.com/assets/js/crypto-js.min.js');
}
function decrypt(str) {
  const KEY = localStorage.getItem("aesKey");
  const IV = localStorage.getItem("aesVi");
  if(!KEY || !IV || !CryptoJS){
    return str;
  }
  if(!str){
    return '';
  }
  var key = CryptoJS.enc.Utf8.parse(KEY);
  var iv = CryptoJS.enc.Utf8.parse(IV);
  var decrypted = CryptoJS.AES.decrypt(str, key, { iv: iv, padding: CryptoJS.pad.Pkcs7 });
  var word = decrypted.toString(CryptoJS.enc.Utf8);
  return word;
}
export {
  decrypt,
  initCpypto
}
